package com.mongodb.config;

import com.mongodb.MongoClientOptions;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xiaochi
 * @date 2022/8/9 11:47
 * @desc MongoDbConfig
 */
@Configuration
public class MongoDbConfig {

    /**
     * mongodb 隔太久查询数据总是报错com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message
     * @return
     */
    @Bean
    public MongoClientOptions mongoClientOptions(){
        return MongoClientOptions.builder().maxConnectionIdleTime(60000).build();
    }
}
